package com.cxf.windex.biz;

import com.cxf.windex.base.biz.BaseBiz;
import com.cxf.windex.base.util.DateUtil;
import com.cxf.windex.entity.HumanResources;
import com.cxf.windex.mapper.HumanResourcesMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;

/**
 * 人力资源招聘信息Biz 业务
 *
 * @author chenxf
 * @version 1.0
 * @date 2018-12-17 10:54
 **/
@Service
public class HumanResourcesBiz extends BaseBiz<HumanResourcesMapper, HumanResources> {

    /**
     * 意见反馈列表
     *
     * @param limit 数量
     * @param offset 页码
     * @param status 状态
     * @return
     */
    public List<HumanResources> list(int limit, int offset,  String status) {
        Example example = new Example(HumanResources.class);
        Example.Criteria criteria = example.createCriteria();
        if(StringUtils.isNotBlank(status)){
            criteria .andEqualTo("status", status);
        }

        criteria.andLessThanOrEqualTo("beginTime",new Date());
        criteria.andGreaterThanOrEqualTo("endTime", new Date());
        example.setOrderByClause("order_num asc");
        PageHelper.startPage(offset, limit);
        return selectByExample(example);
    }

    /**
     * 保存人力资源信息
     * @param entity 人力资源信息
     */
    public void save(HumanResources entity){
        if(entity.getId()==null||entity.getId()==0){
            insertSelective(entity);
        }else{
            updateSelectiveById(entity);
        }
    }
}
